import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/Account/Login',
    method: 'post',
    data
  })
}

export function getInfo(id) {
  return request({
    url: '/Account/AppUsers/' + id,
    method: 'get'
    // params: { token },
    // 此时不用给header，因为在axios对象中Request拦截器中封装了Authorization
  })
}

export function getCount() {
  return request({
    url: '/Account/AppUsersCount',
    method: 'get'
    // params: { token },
    // 此时不用给header，因为在axios对象中Request拦截器中封装了Authorization
  })
}

export function logout() {
  return request({
    url: '/Account/SignOut',
    method: 'post'
  })
}

// 根据roleId拿到指定的Users
export function fetchUserListByRoleId(query) {
  return request({
    url: '/Account/AppUsersByRoleId/' + query.roleId,
    method: 'get',
    params: query
  })
}

// 拿到Users
export function fetchUserList() {
  return request({
    url: '/Account/AppUsers',
    method: 'get'
    // params: query
  })
}

// 拿到UsersiJPaged
export function fetchUserListPaged(query) {
  return request({
    url: '/Account/AppUsersPaged',
    method: 'get',
    params: query
  })
}

// Create User
export function createUser(user) {
  return request({
    url: '/Account/RegisterUser',
    method: 'post',
    data: user
  })
}

// Create PM
export function createPm(user) {
  return request({
    url: '/Account/RegisterProductManager',
    method: 'post',
    data: user
  })
}

// Update info
export function UpdateInfo(user) {
  return request({
    url: '/Account/ChangeAppUserInfo',
    method: 'put',
    data: user
  })
}

// AscensionAppUser
export function AscensionAppUser(user) {
  return request({
    url: '/Account/AscensionAppUser',
    method: 'put',
    data: user
  })
}

// ReduceAppUser
export function ReduceAppUser(user) {
  return request({
    url: '/Account/ReduceAppUser',
    method: 'put',
    data: user
  })
}

// ReduceAppUser
export function ChangePassword(data) {
  return request({
    url: '/Account/ChangePassword',
    method: 'put',
    data: data
  })
}

// DeleteAppUserInfo
export function DeleteAppUserInfo(id) {
  return request({
    url: '/Account/' + id,
    method: 'delete'
  })
}
